plugin.ts 1.4 KB

12345678910111213141516171819202122232425
  1. /** dsh plugin forwards pnpm through the shared profile package operations. */
  2. import { runPluginCommand } from '@deepseek-ai/dsh-plugin-manager/operations'
  3. import { INSTALL_ANCHOR } from './profile-boot.ts'
  4. import { resolveProfileDir } from '@deepseek-ai/dsh-app-boot'
  5. import { join } from 'node:path'
  6. /** Run package management for a profile.
  7. * @param profile Profile name.
  8. * @param args Pnpm arguments relative to the invoking directory.
  9. * @returns Pnpm exit code.
  10. */
  11. export async function runPlugin(profile: string, args: readonly string[]): Promise<number> {
  12. const result = await runPluginCommand({ profile, installAnchor: INSTALL_ANCHOR, cwd: process.cwd() }, args, {
  13. execution: 'cli',
  14. outputBytes: 16384,
  15. lockWaitMs: 120000,
  16. onOutput: (text, stream) => { process[stream].write(text) },
  17. })
  18. if (result.exitCode === 127) process.stderr.write('dsh: pnpm was not found; install pnpm and make it available on PATH.\n')
  19. if (result.exitCode !== 0) process.stderr.write(`dsh: pnpm failed; diagnostics: ${result.logPath}\n`)
  20. if (result.exitCode !== 0 && args.some(argument => /^git\+|^github:|\.git(?:#|$)/.test(argument))) {
  21. process.stderr.write(`dsh: git-hosted plugins build on install via their prepare script, which pnpm blocks until allowed — add the exact key pnpm printed above under allowBuilds in ${join(resolveProfileDir(profile), 'pnpm-workspace.yaml')}, then re-run\n`)
  22. }
  23. return result.exitCode
  24. }