Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ package-lock.json
/site_docs
/coverage
/packages/nutui-jdharmony
/packages/nutui-jdharmonycpp

# local env files
.env.local
Expand Down
9 changes: 0 additions & 9 deletions .npmrc

This file was deleted.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@
"dev:taro:h5:jmapp": "pnpm --dir ./packages/nutui-taro-demo dev:h5:jmapp",
"dev:taro:alipay": "pnpm --dir ./packages/nutui-taro-demo dev:alipay",
"dev:taro:harmony": "pnpm run update:taro:entry && pnpm --dir ./packages/nutui-taro-demo dev:harmony",
"dev:taro:jdharmony": "pnpm run clone:jdharmony && pnpm run update:taro:entry && pnpm --dir ./packages/nutui-taro-demo dev:jdharmony",
"dev:taro:jdharmony": "pnpm run clone:jdharmony && pnpm run update:taro:entry && pnpm --dir ./packages/nutui-taro-demo dev:jdharmony",
Copy link
Collaborator

Choose a reason for hiding this comment

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

从 Taro 的规划看,这块可以删除,以 cpp 为准。

"dev:taro:jdharmonycpp": "pnpm run clone:jdharmony cpp && pnpm run update:taro:entry && pnpm --dir ./packages/nutui-taro-demo dev:jdharmonycpp",
"dev:taro:jdhybrid": "pnpm run update:taro:entry && pnpm --dir ./packages/nutui-taro-demo dev:jdhybrid",
"clone:jdharmony": "node ./scripts/harmony/clone-jdharmony.js",
"update:taro:entry": "node ./scripts/rn/update-taro-entry",
Expand Down
17 changes: 13 additions & 4 deletions packages/nutui-taro-demo/config/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@ let plugins = !['harmony', 'jdharmony', 'rn', 'jdrn'].includes(
: []

if (
process.env.TARO_ENV === 'harmony' ||
process.env.TARO_ENV === 'jdharmony'
process.env.TARO_ENV === 'harmony'
) {
plugins.push('@tarojs/plugin-platform-harmony-ets')
}
Expand Down Expand Up @@ -50,13 +49,17 @@ if (process.env.TARO_ENV === 'jdhybrid') {
if (process.env.TARO_ENV === 'jdharmony') {
plugins = ['@jdtaro/taro-platform-jdharmony']
Copy link
Collaborator

Choose a reason for hiding this comment

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

jdharmony 相关应该都可以删掉了

}
if (process.env.TARO_ENV === 'jdharmony_cpp') {
plugins = ['@jdtaro/plugin-platform-jdharmony-cpp']
}
Comment on lines +52 to +54
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

建议统一 plugins 的赋值方式

在针对不同的 TARO_ENV 时,部分条件使用了直接赋值 plugins 的方式,例如:

if (process.env.TARO_ENV === 'jdharmony_cpp') {
    plugins = ['@jdtaro/plugin-platform-jdharmony-cpp']
}

而其他条件则使用了 plugins.push() 方法,例如:

if (process.env.TARO_ENV === 'harmony') {
    plugins.push('@tarojs/plugin-platform-harmony-ets')
}

为了代码的一致性和可读性,建议统一 plugins 的赋值方式,避免混淆。

// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-expect-error
// if (process.env.TARO_ENV === 'jdharmony') {
// plugins = ['@test/taro-platform-jdharmony']
// }

const isHarmony = process.env.TARO_ENV === 'harmony'
const isHarmonycpp = process.env.TARO_ENV === 'jdharmony_cpp'

const config = {
projectName: 'first',
Expand Down Expand Up @@ -121,18 +124,24 @@ const config = {
framework: 'react',
// harmony 相关配置
harmony: {
ohPackage: {
dependencies: {
'@jd-oh/taro_library': '2.0.70',
'@jd-oh/taro_cpp_library': '0.0.88-beta.0'
},
},
// 将编译方式设置为使用 Vite 编译
compiler: { type: 'vite', vitePlugins: [injectScss()] },
// 【必填】鸿蒙主应用的绝对路径,例如:
projectPath: path.resolve(process.cwd(), isHarmony ? '../nutui-harmony' : '../nutui-jdharmony'),
projectPath: path.resolve(process.cwd(), isHarmony ? '../nutui-harmony' : isHarmonycpp ? '../nutui-jdharmonycpp' : '../nutui-jdharmony'),
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

检查 projectPath 的条件逻辑

projectPath 中,新增了对 isHarmonycpp 的判断:

projectPath: path.resolve(process.cwd(), isHarmony ? '../nutui-harmony' : isHarmonycpp ? '../nutui-jdharmonycpp' : '../nutui-jdharmony'),

请确认该逻辑满足预期,确保当 TARO_ENVjdharmony_cpp 时,路径能够正确解析。

// 【可选】HAP 的名称,默认为 'entry'
hapName: isHarmony ? 'entry' : 'library',
useNesting: true,
postcss: {
pxtransform: {
enable: true,
// 包含 `nut-` 的类名选择器中的 px 单位不会被解析
config: { selectorBlackList: ['nut-', 'demo', 'index', 'page'] },
// config: { selectorBlackList: ['nut-', 'demo', 'index', 'page'] },
},
url: {
enable: true,
Expand Down
44 changes: 23 additions & 21 deletions packages/nutui-taro-demo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
"build:jdhybrid": "taro build --type jdhybrid",
"dev:harmony": "npm run build:harmony -- --watch",
"dev:jdharmony": "pnpm exec taro build native-components --type jdharmony",
"dev:jdharmonycpp": "pnpm exec taro build native-components --type jdharmony_cpp",
"dev:weapp": "npm run build:weapp -- --watch",
"dev:swan": "npm run build:swan -- --watch",
"dev:alipay": "npm run build:alipay -- --watch",
Expand Down Expand Up @@ -57,25 +58,26 @@
"@jdtaro/plugin-platform-jdhybrid": "0.2.1",
"@jdtaro/plugin-platform-jdrn": "2.0.0-beta.0",
"@jdtaro/taro-platform-jdharmony": "2.0.70",
"@jdtaro/plugin-platform-jdharmony-cpp": "0.0.88-beta.0",
"@nutui/touch-emulator": "^1.0.0",
"@pmmmwh/react-refresh-webpack-plugin": "^0.5.11",
"@tarojs/components": "4.0.2",
"@tarojs/helper": "4.0.2",
"@tarojs/plugin-framework-react": "4.0.2",
"@tarojs/plugin-html": "4.0.2",
"@tarojs/plugin-platform-alipay": "4.0.2",
"@tarojs/plugin-platform-h5": "4.0.2",
"@tarojs/plugin-platform-jd": "4.0.2",
"@tarojs/plugin-platform-qq": "4.0.2",
"@tarojs/plugin-platform-swan": "4.0.2",
"@tarojs/plugin-platform-tt": "4.0.2",
"@tarojs/plugin-platform-weapp": "4.0.2",
"@tarojs/react": "4.0.2",
"@tarojs/router": "4.0.2",
"@tarojs/runtime": "4.0.2",
"@tarojs/shared": "4.0.2",
"@tarojs/taro": "4.0.2",
"@tarojs/taro-h5": "4.0.2",
"@tarojs/components": "4.0.0-beta.138",
"@tarojs/helper": "4.0.0-beta.138",
"@tarojs/plugin-framework-react": "4.0.0-beta.138",
"@tarojs/plugin-html": "4.0.0-beta.138",
"@tarojs/plugin-platform-alipay": "4.0.0-beta.138",
"@tarojs/plugin-platform-h5": "4.0.0-beta.138",
"@tarojs/plugin-platform-jd": "4.0.0-beta.138",
"@tarojs/plugin-platform-qq": "4.0.0-beta.138",
"@tarojs/plugin-platform-swan": "4.0.0-beta.138",
"@tarojs/plugin-platform-tt": "4.0.0-beta.138",
"@tarojs/plugin-platform-weapp": "4.0.0-beta.138",
"@tarojs/react": "4.0.0-beta.138",
"@tarojs/router": "4.0.0-beta.138",
"@tarojs/runtime": "4.0.0-beta.138",
"@tarojs/shared": "4.0.0-beta.138",
"@tarojs/taro": "4.0.0-beta.138",
"@tarojs/taro-h5": "4.0.0-beta.138",
"babel-plugin-import": "^1.13.8",
"lodash.isequal": "^4.5.0",
"lodash.kebabcase": "^4.1.1",
Expand All @@ -87,10 +89,10 @@
},
"devDependencies": {
"@babel/core": "^7.23.9",
"@tarojs/cli": "4.0.2",
"@tarojs/plugin-platform-harmony-ets": "4.0.2",
"@tarojs/vite-runner": "4.0.2",
"@tarojs/webpack5-runner": "4.0.2",
"@tarojs/cli": "4.0.0-beta.138",
"@tarojs/plugin-platform-harmony-ets": "4.0.0-beta.138",
"@tarojs/vite-runner": "4.0.0-beta.138",
"@tarojs/webpack5-runner": "4.0.0-beta.138",
Comment on lines +92 to +95
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

更新 @tarojs 开发依赖版本

@tarojs/cli、@tarojs/plugin-platform-harmony-ets、@tarojs/vite-runner 和 @tarojs/webpack5-runner 的版本也已更新到 4.0.0-beta.138。

这些更新与之前提到的 @tarojs 运行时依赖版本更新保持一致。然而,同样存在使用 beta 版本的潜在风险。请确保这些更新不会影响构建过程或引入新的开发环境问题。

建议在合并之前,在隔离的环境中全面测试构建和开发工作流程,以确保兼容性和稳定性。

"@types/react": "^18.2.57",
"@types/react-dom": "^18.2.19",
"@types/react-router-dom": "^5.3.3",
Expand Down
13 changes: 9 additions & 4 deletions scripts/harmony/clone-jdharmony.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,30 @@ const os = require('os')
const path = require('path')
const { remove, ensureDir } = require('fs-extra')
const fs = require('fs')
const args = process.argv.splice(2)

const home = os.homedir()
const temp = `${process.cwd()}/packages`

console.log('args', args)

const platform = args && args[0] === 'cpp' ? 'jdharmonycpp' : 'jdharmony'

async function cloneJdHarmony() {
// 填写coding地址
const remote = ''
const branch = 'master'
const branch = args && args[0] === 'cpp' ? 'master-cpp': 'master'
const git = simpleGit({
baseDir: temp,
})
console.log(`Clone jdharmony, branch: ${branch}`)
console.log(`Clone ${platform}, branch: ${branch}`)

await git.clone(remote, ['-b', branch, '--depth', '1'])

console.log(`Clone completed successfully.`)
// 修改文件夹名称
const harmonyPath = path.join(temp, 'JDHarmony')
const harmonyPathNew = path.join(temp, 'nutui-jdharmony')
const harmonyPathNew = path.join(temp, `nutui-${platform}`)
Comment on lines 28 to +29
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

路径修改正确,但存在潜在问题

新目录路径的修改正确地反映了所选平台,使用模板字符串构建路径的方法很恰当。

然而,第28行的 harmonyPath 仍然使用静态名称 'JDHarmony'。这可能导致在某些情况下找不到正确的目录。建议修改如下:

const harmonyPath = path.join(temp, `JDHarmony-${platform}`)

这样可以确保 harmonyPath 与克隆的仓库名称一致。

Also applies to: 42-42

await remove(harmonyPathNew)
await ensureDir(harmonyPathNew)
fs.renameSync(harmonyPath, harmonyPathNew)
Expand All @@ -34,7 +39,7 @@ async function clone() {

// 判断temp目录是否存在JDHarmony文件夹,如果不存在不存在则执行clone()

const harmonyPath = path.join(temp, 'nutui-jdharmony')
const harmonyPath = path.join(temp, `nutui-${platform}`)
if (!fs.existsSync(harmonyPath)) {
clone()
console.log(`Clone JDHarmony successfully.`)
Expand Down