dsh-plugin 2.0.0 → 2.0.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.
@@ -15,7 +15,7 @@ import type { InstallResult, InstallTask, Invocation, QueueItem } from './instal
15
15
  import { CAPTURE_LIMIT_BYTES, MAX_TASKS, MAX_TASK_LINES } from './install-types.ts'
16
16
  import { npmTooLowMarker } from './npm-check.ts'
17
17
  import { registryMissingMarker } from './registry-check.ts'
18
- import { backfillOperationLog, operationLogPathOf } from './operation-log.ts'
18
+ import { backfillOperationLog, createOperationLogTap, operationLogPathOf } from './operation-log.ts'
19
19
  import { cleanLine, estimateProgress } from '../profile/progress.ts'
20
20
  import type { LoaderHandle } from '../loader.ts'
21
21
  import { hasClientUi, isDshPlugin, mountLoadedEntry, removeLoadedEntry } from '../loader.ts'
@@ -767,6 +767,8 @@ export async function runPluginMutation(options: {
767
767
  /** 全局 npm 安装(官方 `npm install -g <pkgs>`):非空时执行全局安装,不进任何 profile、无需宿主重启 */
768
768
  globalNpm?: string[]
769
769
  }): Promise<InstallResult> {
770
+ // operation 日志只在运行期存在(宿主结束后可能清掉),先开抓取,退出后按路径读作兜底
771
+ const logTap = createOperationLogTap(profileDirectory(options.profile))
770
772
  let result = await spawnMutation(options)
771
773
  // allowBuilds 放行 / 装后入口校验都是 profile 专属(pnpm 装进 profile 的场景);
772
774
  // 全局 npm 安装直接走 npm,无 pnpm allowBuilds 拦截、也不进 profile,跳过这两类恢复
@@ -805,6 +807,8 @@ export async function runPluginMutation(options: {
805
807
  }
806
808
  }
807
809
  }
810
+ // 重试会产生新的 operation 日志,运行期抓取到此为止
811
+ const tappedLog = logTap.stop()
808
812
  // pnpm 安装本身成功,但目标包声明分发的文件缺失(分发物缺构建产物 / 缺声明的补丁)→ 判为失败:
809
813
  // 撤销刚登记的待重启,避免用户重启时宿主加载残缺包直接崩溃。
810
814
  // 全局 npm 安装不进 profile(profile deps 里没有这些包),跳过入口校验
@@ -827,7 +831,7 @@ export async function runPluginMutation(options: {
827
831
  // 只在输出本就不含错误码时回捞 —— pnpm 已回显报错时无需多读一次文件。
828
832
  if (result.exitCode !== 0 && !result.timedOut && !/\bERR_[A-Z0-9_]+\b/.test(`${result.stderr}\n${result.stdout}`)) {
829
833
  const output = `${result.stderr}\n${result.stdout}`
830
- const backfilled = backfillOperationLog(output)
834
+ const backfilled = tappedLog !== '' ? tappedLog : backfillOperationLog(output)
831
835
  if (backfilled !== null) {
832
836
  if (options.task && options.task.status !== 'cancelled') {
833
837
  pushLine(options.task, '[pnpm log] DSH did not echo pnpm output — recovered the operation log from disk')