-
Notifications
You must be signed in to change notification settings - Fork 285
feat: 接入 harmony cpp 版本 #2646
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
feat: 接入 harmony cpp 版本 #2646
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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') | ||
} | ||
|
@@ -50,13 +49,17 @@ if (process.env.TARO_ENV === 'jdhybrid') { | |
if (process.env.TARO_ENV === 'jdharmony') { | ||
plugins = ['@jdtaro/taro-platform-jdharmony'] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion 建议统一 在针对不同的 if (process.env.TARO_ENV === 'jdharmony_cpp') {
plugins = ['@jdtaro/plugin-platform-jdharmony-cpp']
} 而其他条件则使用了 if (process.env.TARO_ENV === 'harmony') {
plugins.push('@tarojs/plugin-platform-harmony-ets')
} 为了代码的一致性和可读性,建议统一 |
||
// 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', | ||
|
@@ -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'), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 检查 在 projectPath: path.resolve(process.cwd(), isHarmony ? '../nutui-harmony' : isHarmonycpp ? '../nutui-jdharmonycpp' : '../nutui-jdharmony'), 请确认该逻辑满足预期,确保当 |
||
// 【可选】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, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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", | ||
|
@@ -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", | ||
|
@@ -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
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
"@types/react": "^18.2.57", | ||
"@types/react-dom": "^18.2.19", | ||
"@types/react-router-dom": "^5.3.3", | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 路径修改正确,但存在潜在问题 新目录路径的修改正确地反映了所选平台,使用模板字符串构建路径的方法很恰当。 然而,第28行的 const harmonyPath = path.join(temp, `JDHarmony-${platform}`) 这样可以确保 Also applies to: 42-42 |
||
await remove(harmonyPathNew) | ||
await ensureDir(harmonyPathNew) | ||
fs.renameSync(harmonyPath, harmonyPathNew) | ||
|
@@ -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.`) | ||
|
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.
从 Taro 的规划看,这块可以删除,以 cpp 为准。