Enhancement: apply pubspec.yaml `dependency_overrides` in Dart scans

未关闭
#678 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

@vibgrate-team 已经在做这个了。

开始于 2026年11月13日。

  • #680 来自 @vibgrate-team —— 未关闭

评估

难度
3/5
预计耗时
半天
新手友好度
62/100
Issue 类型
功能
描述清晰度
基本清楚
活跃度
活跃
技术栈
dart, flutter, typescript
领域
tooling

调研方向

Start with parsePubspecYaml in src/core-open/scanners/dart-scanner.ts (around lines 203-300), where the section tracking only handles dependencies and dev_dependencies. Teach it to read dependency_overrides entries in the same forms (one-line, version map, path, git), letting the override spec replace the declared spec for packages that appear in both, and decide how override-only packages are reported. Done when the example reports http at 1.2.1, overridden dev packages keep their dev flag, projects without the section are unchanged, and a new test beside test/dart-pubspec-map.test.ts passes under npm test.

由索引模型根据 Issue 内容生成。

描述

enhancement

Context

In Dart and Flutter projects, dependency_overrides: in pubspec.yaml forces the version that actually gets resolved, whatever dependencies: or dev_dependencies: ask for:

dependencies:
  http: ^0.13.0

dependency_overrides:
  http: 1.2.1

parsePubspecYaml in src/core-open/scanners/dart-scanner.ts (around lines 203–300) only enters a section for dependencies: and dev_dependencies:. Any other top-level key, including dependency_overrides:, resets the section, so overrides are ignored. As a result, a project scanned without a pubspec.lock reports the ^0.13.0 constraint for http, even though the project builds with 1.2.1. A package that appears only in dependency_overrides is not reported at all.

What to do

  • Read dependency_overrides: entries in the same forms already supported for the other sections (one-line version, { version: … } maps, path: and git: entries).
  • When a package is both declared and overridden, use the override's spec for that package's row and keep it as a production or development dependency according to where it was declared.
  • Decide what to do with override-only packages (for example, report them as production rows) and write the choice down in the function's doc comment.
  • Add a test next to test/dart-pubspec-map.test.ts.

Acceptance

  • With the example above, vg scan reports http at 1.2.1, not ^0.13.0.
  • An overridden dev_dependencies package keeps its development flag.
  • Projects with no dependency_overrides: section produce exactly the same output as before.
  • New test passes with npm test.
主要语言
TypeScript
星标
4
派生
3
平均合并
1 天 22 小时
30 天内合并 PR
76

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

vibgrate/cli 的其他 Issue

查看 vibgrate/cli 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。