Skip to content

fix: 排序 platforms 确保生成 pages.json 的一致性#257

Merged
edwinhuish merged 1 commit intouni-helper:mainfrom
gd4Ark:feature/sort-platforms-str
Oct 24, 2025
Merged

fix: 排序 platforms 确保生成 pages.json 的一致性#257
edwinhuish merged 1 commit intouni-helper:mainfrom
gd4Ark:feature/sort-platforms-str

Conversation

@gd4Ark
Copy link
Contributor

@gd4Ark gd4Ark commented Oct 24, 2025

Description 描述

在构建过程中,会根据之前在 pages.json 文件中记录的注释来获取现有 platform,并在此基础上添加本次构建的新平台内容,这样可以避免在构建其他平台时覆盖掉现有平台的 pages.json 文件内容。

然而,当重新构建一个已存在的 platform 时,由于每次都会先将当前 platform 从 platforms 中移除,然后再将其添加回去,这会导致当前 platform 出现在注释的末尾。在多个 platform 交替构建的情况下,pages.json 的注释内容会不断变化。

因此,在 push platform 后进行排序,可以确保在配置不变的情况下,生成的 pages.json 文件内容保持一致。

Summary by CodeRabbit

  • Bug Fixes
    • Improved platform aggregation logic to ensure consistent ordering of platform information.

@coderabbitai
Copy link

coderabbitai bot commented Oct 24, 2025

Walkthrough

Modified the mergePlatformItems function in the context module to sort the platforms array when aggregating duplicate items by key. Previously, only the platformStr was updated; now both the platforms array and platformStr are properly ordered during platform merging.

Changes

Cohort / File(s) Summary
Platform aggregation logic
packages/core/src/context.ts
Updated mergePlatformItems to sort platforms array after pushing currentPlatform when duplicate items are merged, affecting platform ordering in platformStr

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Suggested labels

size/M

Poem

🐰 Platforms hop and platforms play,
Now sorted in the proper way,
With arrays arranged just right,
The merge is clean, the order bright! 🎯

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The title "fix: 排序 platforms 确保生成 pages.json 的一致性" (which translates to "fix: Sort platforms to ensure consistency in generating pages.json") is fully related to the main change in the pull request. The raw summary shows that the code modification sorts the platforms array after pushing the currentPlatform, and the PR objectives explicitly state the problem being solved is inconsistent pages.json generation due to unpredictable platform ordering, with the proposed solution being to sort platforms. The title is concise, specific, and accurately reflects the primary change without misleading terminology.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 8e3c2fa and ecb0d05.

📒 Files selected for processing (1)
  • packages/core/src/context.ts (1 hunks)
🔇 Additional comments (1)
packages/core/src/context.ts (1)

597-599: LGTM! Sorting ensures deterministic platform ordering.

The addition of .sort() after pushing the platform maintains consistency with the existing pattern of sorting platforms throughout this function (see lines 523 and 557). This change ensures that the generated pages.json content remains stable regardless of build order, directly addressing the issue described in the PR objectives.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@edwinhuish edwinhuish merged commit fa1c4f6 into uni-helper:main Oct 24, 2025
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants