From 71f4d9c35f780463d04da3fe81e2e5c9ab000e2c Mon Sep 17 00:00:00 2001 From: HeYanbo Date: Tue, 7 Jan 2025 13:57:07 +0800 Subject: [PATCH 1/3] update hvigorfile.ts file --- .../harmony/entry/hvigorfile.ts | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/Example/harmony_use_pushy/harmony/entry/hvigorfile.ts b/Example/harmony_use_pushy/harmony/entry/hvigorfile.ts index d3d3aa0d..054a94b1 100644 --- a/Example/harmony_use_pushy/harmony/entry/hvigorfile.ts +++ b/Example/harmony_use_pushy/harmony/entry/hvigorfile.ts @@ -1,6 +1,7 @@ import { hapTasks } from '@ohos/hvigor-ohos-plugin'; import fs from 'fs'; import path from 'path'; + export function generatePushyBuildTime(str?: string) { return { pluginId: 'PushyBuildTimePlugin', @@ -13,11 +14,22 @@ export function generatePushyBuildTime(str?: string) { if (!fs.existsSync(dirPath)) { fs.mkdirSync(dirPath, { recursive: true }); } + const moduleJsonPath = path.resolve(__dirname, './oh-package.json5'); + let versionName = ''; + if (fs.existsSync(moduleJsonPath)) { + const moduleContent = fs.readFileSync(moduleJsonPath, 'utf-8'); + const versionMatch = moduleContent.match(/"version":\s*"([^"]+)"/); + if (versionMatch && versionMatch[1]) { + versionName = versionMatch[1]; + } + } const buildTime = new Date().toISOString(); - const metaContent = { pushy_build_time : buildTime }; + const metaContent = { + pushy_build_time: buildTime, + versionName: versionName + }; fs.writeFileSync(metaFilePath, JSON.stringify(metaContent, null, 4)); console.log(`Build time written to ${metaFilePath}`); - }, dependencies: [], postDependencies: ['default@BuildJS'] From db0a4fb822d482881c12e4921fa19fee5dfee0fd Mon Sep 17 00:00:00 2001 From: HeYanbo Date: Sun, 12 Jan 2025 03:44:40 +0800 Subject: [PATCH 2/3] change versionName get logic --- Example/harmony_use_pushy/harmony/entry/hvigorfile.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Example/harmony_use_pushy/harmony/entry/hvigorfile.ts b/Example/harmony_use_pushy/harmony/entry/hvigorfile.ts index 054a94b1..a1641ea7 100644 --- a/Example/harmony_use_pushy/harmony/entry/hvigorfile.ts +++ b/Example/harmony_use_pushy/harmony/entry/hvigorfile.ts @@ -14,11 +14,11 @@ export function generatePushyBuildTime(str?: string) { if (!fs.existsSync(dirPath)) { fs.mkdirSync(dirPath, { recursive: true }); } - const moduleJsonPath = path.resolve(__dirname, './oh-package.json5'); + const moduleJsonPath = path.resolve(__dirname, '../AppScope/app.json5'); let versionName = ''; if (fs.existsSync(moduleJsonPath)) { const moduleContent = fs.readFileSync(moduleJsonPath, 'utf-8'); - const versionMatch = moduleContent.match(/"version":\s*"([^"]+)"/); + const versionMatch = moduleContent.match(/"versionName":\s*"([^"]+)"/); if (versionMatch && versionMatch[1]) { versionName = versionMatch[1]; } From 4726f684152e4c34141b8c64e037edcc36de8d01 Mon Sep 17 00:00:00 2001 From: HeYanbo Date: Sun, 12 Jan 2025 03:47:12 +0800 Subject: [PATCH 3/3] change post logic for harmony --- src/client.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/client.ts b/src/client.ts index cbd1c16e..e1b3b04f 100644 --- a/src/client.ts +++ b/src/client.ts @@ -205,7 +205,10 @@ export class Pushy { // @ts-ignore delete fetchBody.buildTime; } - const body = JSON.stringify(fetchBody); + let body = JSON.stringify(fetchBody); + if (Platform.OS === 'harmony') { + body = fetchBody; + } const fetchPayload = { method: 'POST', headers: {