-
Notifications
You must be signed in to change notification settings - Fork 4.9k
Update BaseCi.ts #18182
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Update BaseCi.ts #18182
Conversation
支付宝私钥文件路径,在获取项目属性和上传时用于鉴权privateKeyPath和privateKey之间只需要填写一个,不是必填
Walkthrough在 packages/taro-plugin-mini-ci/src/BaseCi.ts 中,将 AlipayConfig 接口的 privateKeyPath 与 privateKey 字段从必填改为可选(string → string?)。无运行时逻辑或控制流变更,其余代码不变。 Changes
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~3 minutes Poem
✨ Finishing Touches
🧪 Generate unit tests
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR/Issue comments)Type Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this 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
📒 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]
只改这里没有实际作用的,只是类型约束,后面还有逻辑验证 |
支付宝私钥文件路径,在获取项目属性和上传时用于鉴权privateKeyPath和privateKey之间只需要填写一个,不是必填
这个 PR 做了什么? (简要描述所做更改)
这个 PR 是什么类型? (至少选择一个)
这个 PR 涉及以下平台:
Summary by CodeRabbit