dsh-harbor-evolution 0.8.2 → 0.9.2

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.
package/lib/process.js CHANGED
@@ -1,10 +1,36 @@
1
1
  import { spawn } from 'node:child_process'
2
+ import { existsSync } from 'node:fs'
3
+ import path from 'node:path'
4
+
5
+ const DOCKER_DESKTOP_BIN = '/Applications/Docker.app/Contents/Resources/bin'
6
+
7
+ /**
8
+ * On macOS, Docker Desktop keeps `docker-credential-desktop` (and the other
9
+ * credential helpers) inside the app bundle, outside the default PATH that a
10
+ * GUI-launched Harness inherits. A missing helper makes `docker build`/`pull`
11
+ * fail with `exec: "docker-credential-desktop": executable file not found in
12
+ * $PATH` even though the CLI and daemon are reachable. Prepend that directory
13
+ * to PATH for every child process we spawn so Harbor inherits a resolvable
14
+ * helper. The change is macOS-only, existence-checked, and idempotent.
15
+ */
16
+ export function dockerDesktopAwareEnv(env, {
17
+ platform = process.platform,
18
+ pathExists = existsSync,
19
+ } = {}) {
20
+ const base = env ?? process.env
21
+ if (platform !== 'darwin') return base
22
+ if (!pathExists(DOCKER_DESKTOP_BIN)) return base
23
+ const current = String(base.PATH ?? '')
24
+ const segments = current.split(path.delimiter).filter(Boolean)
25
+ if (segments.includes(DOCKER_DESKTOP_BIN)) return base
26
+ return { ...base, PATH: [DOCKER_DESKTOP_BIN, ...segments].join(path.delimiter) }
27
+ }
2
28
 
3
29
  export function runProcess(command, args, options = {}) {
4
30
  return new Promise((resolve, reject) => {
5
31
  const child = spawn(command, args, {
6
32
  cwd: options.cwd,
7
- env: options.env ?? process.env,
33
+ env: dockerDesktopAwareEnv(options.env ?? process.env),
8
34
  shell: false,
9
35
  stdio: [options.input === undefined ? 'ignore' : 'pipe', 'pipe', 'pipe'],
10
36
  })
@@ -3,5 +3,4 @@ import { readFileSync } from 'node:fs'
3
3
  const packageJson = JSON.parse(readFileSync(new URL('../package.json', import.meta.url), 'utf8'))
4
4
 
5
5
  export const DSH_RUNTIME_VERSION = packageJson.harborEvolution.dshRuntimeVersion
6
- export const CANDIDATE_ACP_PACKAGE = packageJson.harborEvolution.candidateAcpPackage
7
6
  export const RUNTIME_POLICY = packageJson.harborEvolution.runtimePolicy