-
Notifications
You must be signed in to change notification settings - Fork 287
fix: 组件库基于 jdTaro 的改造&&所有端demo合成一个 #2476
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
Conversation
Walkthrough此次更改涉及多个文件的修改,主要集中在 ESLint 忽略规则、构建脚本、配置管理及新增的 React 组件。这些更改旨在提升项目代码的质量和维护性,同时增强 Taro 框架的兼容性,反映出项目结构的重组与功能的扩展。 Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant App
participant BuildSystem
participant ESLint
User->>App: 触发构建请求
App->>BuildSystem: 更新配置和脚本
BuildSystem->>ESLint: 处理文件的 ESLint 忽略规则
ESLint-->>BuildSystem: 文件处理完成
BuildSystem-->>User: 构建完成
Recent review detailsConfiguration used: CodeRabbit UI Files selected for processing (2)
Files skipped from review as they are similar to previous changes (1)
Additional comments not posted (2)
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (invoked as PR comments)
Additionally, you can add CodeRabbit Configuration File (
|
| } | ||
|
|
||
| .index-header .info .h5-h1 { | ||
| &_header { |
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.
_ 建议统一改为 -
| }) | ||
| } | ||
|
|
||
| const onShareAppMessage = (res) => { |
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.
没有这个方法,应该是无法触发 分享~~
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.
没有这个方法,应该是无法触发 分享~~
已还原
| @@ -839,7 +839,7 @@ | |||
| "author": "szg2008" | |||
| }, | |||
| { | |||
| "version": "3.0.0", | |||
| "version": "2.0.0", | |||
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.
这个合并了~~ 可以合一下dev
| .rn_temp/ | ||
| node_modules/ | ||
| .DS_Store | ||
| src/base/ |
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.
这个是不是 后边就不用关注了·~
现在只是需要在开发中的原因?
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.
需要,因为兼容RN未适配的组件不开入口
已修改
| const { remove, ensureDir } = require('fs-extra') | ||
| const fs = require('fs') | ||
|
|
||
| const home = os.homedir() |
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.
改到项目的相对路径比较好~~
另外这个所有人都可以访问吗。所有人都可以执行成功么
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: 7
Outside diff range, codebase verification and nitpick comments (3)
scripts/taro/generate-taro-pages.js (3)
Line range hint
41-43:
错误处理不当在
fs.mkdirSync的回调中处理错误是无效的,建议直接捕获异常。- fs.mkdirSync(dirPath, { recursive: true }, (err) => { - console.log('mkdir error', err) - }) + try { + fs.mkdirSync(dirPath, { recursive: true }) + } catch (err) { + console.log('mkdir error', err) + }
Line range hint
69-69:
硬编码的文件路径建议将文件路径作为可配置参数传递,以提高代码的灵活性和可维护性。
const dirPath = path.join(__dirname, process.env.APP_DIR || `../../packages/nutui-taro-demo/src`)
Line range hint
75-75:
潜在的fse.outputFile问题在
fse.outputFile中,fileString未被修改,建议使用修改后的lines数组。const newFileString = lines.join('\n') fse.outputFile(filePath, newFileString, 'utf8', (error) => { if (error) console.log('Error', error) })
scripts/harmony/clone-jdharmony.js
Outdated
| const temp = `${process.cwd()}/packages` | ||
|
|
||
| async function cloneJdHarmony() { | ||
| const remote = 'git@coding.jd.com:DongDesign/JDHarmony.git' |
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.
硬编码的git远程URL
建议将远程URL作为函数参数传递,以提高代码的灵活性和可维护性。
async function cloneJdHarmony(remote = 'git@coding.jd.com:DongDesign/JDHarmony.git', branch = 'master') {
// ...
}| const harmonyPathNew = path.join(temp, 'nutui-jdharmony') | ||
| await remove(harmonyPathNew) | ||
| await ensureDir(harmonyPathNew) | ||
| fs.renameSync(harmonyPath, harmonyPathNew) |
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.
避免使用同步的fs.renameSync
建议使用异步方法fs.rename来避免阻塞事件循环。
await fs.promises.rename(harmonyPath, harmonyPathNew)|
|
||
| // 判断temp目录是否存在JDHarmony文件夹,如果不存在不存在则执行clone() | ||
|
|
||
| const harmonyPath = path.join(temp, 'nutui-jdharmony') |
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.
硬编码的目录路径
建议将目录路径作为可配置参数传递,以提高代码的灵活性和可维护性。
const harmonyPath = path.join(temp, process.env.HARMONY_DIR || 'nutui-jdharmony')| if (!fs.existsSync(harmonyPath)) { | ||
| clone() | ||
| console.log(`Clone JDHarmony successfully.`) |
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.
潜在的竞争条件
在检查目录是否存在和创建目录之间可能存在竞争条件,建议使用fs-extra的ensureDir方法。
const harmonyPath = path.join(temp, 'nutui-jdharmony')
ensureDir(harmonyPath).then(() => {
console.log(`JDHarmony already exists.`)
}).catch(() => {
clone().then(() => {
console.log(`Clone JDHarmony successfully.`)
})
})| const name = package.name | ||
| const nameLc = package.name.toLowerCase() | ||
| let content = `export default { | ||
| const content = `export default { |
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.
硬编码的文件路径
建议将文件路径作为可配置参数传递,以提高代码的灵活性和可维护性。
const dirPath = path.join(__dirname, process.env.DEMO_DIR || `../../packages/nutui-taro-demo/src/${enName}/pages/${nameLc}`)Tools
Biome
[error] 31-31: Illegal use of reserved keyword
packageas an identifier in strict mode(parse)
| const demoContent = adaptedArray.includes(nameLc) | ||
| ? `import Demo from '@/packages/${nameLc}/demo.taro'; |
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.
潜在的竞争条件
在生成配置文件和生成demo文件之间可能存在竞争条件,建议使用异步方法并链式调用。
fs.promises.writeFile(filePath, content)
.then(() => {
console.log(`生成index.config.ts文件成功`)
return fs.promises.writeFile(demoFilePath, demoContent)
})
.then(() => {
console.log(`生成 index.tsx 文件成功`)
})
.catch((err) => {
console.error('Error', err)
})|
|
||
| const navs = config.nav | ||
|
|
||
| // let fileStr = `@import '../../../styles/font/iconfont.css';` |
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.
非法使用保留关键字package
在严格模式下,package是保留关键字,建议更换变量名。
- const createIndexConfig = (enName, package) => {
+ const createIndexConfig = (enName, pkg) => {Committable suggestion was skipped due to low confidence.
🤔 这个变动的性质是?
🔗 相关 Issue
💡 需求背景和解决方案
☑️ 请求合并前的自查清单
Summary by CodeRabbit
新功能
修复
文档