Skip to content

Conversation

pingjiang
Copy link

@pingjiang pingjiang commented Aug 25, 2025

这个 PR 做了什么? (简要描述所做更改)
fix project config file for ASCF, support compile ascf.config.json to dist

这个 PR 是什么类型? (至少选择一个)

  • 错误修复 (Bugfix) issue: fix #
  • 新功能 (Feature)
  • 代码重构 (Refactor)
  • TypeScript 类型定义修改 (Types)
  • 文档修改 (Docs)
  • 代码风格更新 (Code style update)
  • 构建优化 (Chore)
  • 其他,请描述 (Other, please describe):

这个 PR 涉及以下平台:

  • 所有平台
  • Web 端(H5)
  • 移动端(React-Native)
  • 鸿蒙(Harmony)
  • 鸿蒙容器(Harmony Hybrid)
  • ASCF 元服务
  • 快应用(QuickApp)
  • 所有小程序
  • 微信小程序
  • 企业微信小程序
  • 京东小程序
  • 百度小程序
  • 支付宝小程序
  • 支付宝 IOT 小程序
  • 钉钉小程序
  • QQ 小程序
  • 飞书小程序
  • 快手小程序
  • 头条小程序

Summary by CodeRabbit

  • 新功能
    • 在项目收尾阶段自动生成 ascf.config.json 配置文件。用户无需手动创建或维护,开箱即用,减少配置成本与出错率,并确保不同环境下配置一致。

fix project config file for ASCF
Copy link

coderabbitai bot commented Aug 25, 2025

Walkthrough

在 AscfApp 的 setupTransaction 的 close 包装流程中,于调用 modifyTemplate 与 modifyWebpackConfig 之后,新增调用 generateProjectConfig('ascf.config.json', 'ascf.config.json'),以在 close 阶段生成 ascf.config.json。

Changes

Cohort / File(s) Change Summary
Close 阶段生成项目配置
packages/taro-platform-ascf/src/program.ts
在 setupTransaction 的 close 包装中,紧随 modifyTemplate 与 modifyWebpackConfig 之后新增调用 generateProjectConfig('ascf.config.json', 'ascf.config.json'),以生成 ascf.config.json。

Sequence Diagram(s)

sequenceDiagram
    autonumber
    participant Dev as Developer
    participant App as AscfApp
    participant FS as FileSystem

    Dev->>App: setupTransaction() 完成,进入 close 包装
    App->>FS: modifyTemplate()
    App->>FS: modifyWebpackConfig()
    note right of App: 新增步骤
    App->>FS: generateProjectConfig('ascf.config.json','ascf.config.json')
    FS-->>App: 写入完成
    App-->>Dev: close 完成
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

小兔挥笔改流程,\n> close 末尾添一筹。\n> config 轻声落纸上,\n> ascf.json 入档头。\n> 模板、webpack齐点首,\n> 项目生成更稳妥。

Tip

🔌 Remote MCP (Model Context Protocol) integration is now available!

Pro plan users can now connect to remote MCP servers from the Integrations page. Connect with popular remote MCPs such as Notion and Linear to add more context to your reviews and chats.

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between a6bfe71 and 611e97b.

📒 Files selected for processing (1)
  • packages/taro-platform-ascf/src/program.ts (1 hunks)
🔇 Additional comments (2)
packages/taro-platform-ascf/src/program.ts (2)

40-40: LGTM:新增 generateProjectConfig 调用确保 ascf.config.json 被编译进 dist

调用位置放在 setupTransaction 的 close 阶段,顺序在 modifyTemplate/modifyWebpackConfig 之后,能解决 ASCF 配置文件未输出的问题,方向正确。


40-40: 无需调整 generateProjectConfig 签名或调用方式

经核查:

  • 基类 TaroPlatformBase 中定义

    protected generateProjectConfig(src: string, dist = 'project.config.json') {  }

    与文档注释(@param dist 默认值为 'project.config.json')一致,签名正确。

  • 各平台插件调用方式均显式传入了两个参数:

    • swan:this.generateProjectConfig(PROJECT_JSON, PROJECT_JSON)
    • alipay:this.generateProjectConfig('project.alipay.json', 'mini.project.json')
    • ascf:this.generateProjectConfig('ascf.config.json', 'ascf.config.json')

    均符合基类的 (src: string, dist?: string) 约定。

  • 仅基类内部在处理 mini 平台时会省略第二个参数(使用默认值),属于基类自身逻辑,与各插件的调用无冲突。

结论:当前 ascf 平台对 generateProjectConfig 的调用已与其他平台保持一致,无需修改或统一调用形式。

close () {
this.modifyTemplate(pluginOptions)
this.modifyWebpackConfig()
this.generateProjectConfig('ascf.config.json', 'ascf.config.json')
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

避免硬编码文件名,改用 this.projectConfigJson 以兼容自定义 projectConfigName

类中已定义 projectConfigJson = this.config.projectConfigName || 'ascf.config.json'(见行 14)。此处硬编码 'ascf.config.json' 会忽略调用方通过 config.projectConfigName 的覆盖,破坏可配置性。建议改为使用类属性,或直接依赖默认参数。

建议修改如下:

-        this.generateProjectConfig('ascf.config.json', 'ascf.config.json')
+        this.generateProjectConfig(this.projectConfigJson, this.projectConfigJson)

如果 generateProjectConfig 支持无参且默认取 this.projectConfigJson,也可简化为:

  • 直接调用 this.generateProjectConfig()(仅作说明,不作为本 diff 的必改项)。
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
this.generateProjectConfig('ascf.config.json', 'ascf.config.json')
@@ packages/taro-platform-ascf/src/program.ts
this.generateProjectConfig(this.projectConfigJson, this.projectConfigJson)
🤖 Prompt for AI Agents
In packages/taro-platform-ascf/src/program.ts around line 40 (class defines
projectConfigJson = this.config.projectConfigName || 'ascf.config.json' at line
14), the call this.generateProjectConfig('ascf.config.json', 'ascf.config.json')
hardcodes the filename and ignores caller-provided config.projectConfigName;
change the call to use the class property (this.projectConfigJson) instead of
the string literal, or if generateProjectConfig supports no arguments, call
this.generateProjectConfig() so the method uses the default projectConfigJson;
ensure both parameters (if still required) are replaced with
this.projectConfigJson to preserve configurability.

@Single-Dancer Single-Dancer added this to the 4.1.6 milestone Aug 25, 2025
Copy link

codecov bot commented Aug 25, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 55.07%. Comparing base (a6bfe71) to head (611e97b).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             main   #18246   +/-   ##
=======================================
  Coverage   55.07%   55.07%           
=======================================
  Files         416      416           
  Lines       21561    21561           
  Branches     5301     5245   -56     
=======================================
  Hits        11875    11875           
+ Misses       8035     8033    -2     
- Partials     1651     1653    +2     
Flag Coverage Δ
taro-cli 72.85% <ø> (ø)
taro-runtime 59.87% <ø> (ø)
taro-web 53.19% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.
see 7 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@Single-Dancer Single-Dancer removed this from the 4.1.6 milestone Aug 30, 2025
This was referenced Sep 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants