Skip to content

Conversation

Damoness
Copy link

@Damoness Damoness commented Aug 12, 2025

支付宝私钥文件路径,在获取项目属性和上传时用于鉴权privateKeyPath和privateKey之间只需要填写一个,不是必填

这个 PR 做了什么? (简要描述所做更改)

这个 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

  • 新功能
    • 支持在支付宝相关配置中将私钥路径与私钥设为可选,减少必填项,提升配置灵活性与兼容性;未提供时可采用替代的凭证来源(如环境变量或外部管理),简化不同环境下的集成与部署。

 支付宝私钥文件路径,在获取项目属性和上传时用于鉴权privateKeyPath和privateKey之间只需要填写一个,不是必填
Copy link

coderabbitai bot commented Aug 12, 2025

Walkthrough

在 packages/taro-plugin-mini-ci/src/BaseCi.ts 中,将 AlipayConfig 接口的 privateKeyPath 与 privateKey 字段从必填改为可选(string → string?)。无运行时逻辑或控制流变更,其余代码不变。

Changes

Cohort / File(s) Summary of changes
类型定义调整
packages/taro-plugin-mini-ci/src/BaseCi.ts
将 AlipayConfig 的 privateKeyPath: stringprivateKey: string 改为可选:privateKeyPath?: stringprivateKey?: string;仅类型约束放宽,无其他变更。

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Poem

轻敲键帽两处星,
键影化问号,类型更从容。
兔子提笔笑微风,
私钥可有亦可无,构建仍长虹。
咚咚——CI 跑,一路顺通。

✨ 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: 0

🧹 Nitpick comments (2)
packages/taro-plugin-mini-ci/src/BaseCi.ts (2)

76-79: 注释与类型语义不一致:请将“必须要填写其中一个”更新为“二选一,非必填”

当前将 privateKeyPath/privateKey 改为可选,但行内注释仍写着“必须要填写其中一个”,和本次变更目标不一致,容易误导使用者。

建议直接更新这两处注释,示例 diff 如下:

-  /** 私钥文件路径,在获取项目属性和上传时用于鉴权使用(privateKeyPath和privateKey之间必须要填写其中一个) */
+  /** 私钥文件路径,在获取项目属性和上传时用于鉴权使用(与 privateKey 二选一,非必填) */
   privateKeyPath?: string
-  /** 私钥文本内容,在获取项目属性和上传时用于鉴权使用(privateKeyPath和privateKey之间必须要填写其中一个) */
+  /** 私钥文本内容,在获取项目属性和上传时用于鉴权使用(与 privateKeyPath 二选一,非必填) */
   privateKey?: string

77-79: 类型层面表达“二选一”(可选):可考虑互斥键的类型建模

如果希望在类型层面约束“最多只提供一个,同时允许都不提供”,可以将鉴权配置拆成互斥联合类型,与现有基础配置合并。这是增强型(可选)的类型约束,不影响运行时行为。

可参考如下写法(示意,供后续演进考虑):

// 基础字段(不含鉴权二选一部分)
interface AlipayConfigBase {
  /** 小程序appid */
  appid: string
  /** 工具id */
  toolId: string
  devToolsInstallPath?: string
  clientType?: AlipayClientType
  deleteVersion?: string
}

// 鉴权:二选一,且允许都不提供(第三个分支)
type AlipayAuth =
  | { privateKeyPath: string; privateKey?: never }
  | { privateKey: string; privateKeyPath?: never }
  | {} // 允许都不提供

export type AlipayConfig = AlipayConfigBase & AlipayAuth

如暂不采用此改动,至少在文档上明确“两者均可不填;若两者都提供,是否有优先级”的规则。

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 0a14895 and 1ce5c35.

📒 Files selected for processing (1)
  • packages/taro-plugin-mini-ci/src/BaseCi.ts (1 hunks)
🔇 Additional comments (1)
packages/taro-plugin-mini-ci/src/BaseCi.ts (1)

77-79: 无需修改:privateKeyPath/privateKey 已安全使用

  • 各端配置通过 Joi 校验保证 “二选一”(weapp 永远有 privateKeyPath;jd 永远有 privateKey;alipay 至少有其一)
  • AlipayCI 中先判断 privateKey,再在分支内使用 privateKeyPath,不会直接对 undefined 调用方法
  • WeappCI、JdCI 均直接使用必填字段,类型安全

鉴于以上运行时校验和分支处理,开启 strictNullChecks 下也不会有未检查就访问 undefined 的情况。[js]

This was referenced Aug 16, 2025
@bigmeow
Copy link
Member

bigmeow commented Aug 29, 2025

只改这里没有实际作用的,只是类型约束,后面还有逻辑验证

This was referenced Aug 30, 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