1
0
mirror of https://gitcode.com/gh_mirrors/re/react-native-pushy.git synced 2025-10-28 12:03:11 +08:00
Code Issues Packages Projects Releases Wiki Activity GitHub Gitee

fix hvigor plugin

This commit is contained in:
sunnylqm
2025-10-26 23:10:44 +08:00
parent ba5b35813d
commit e0201d3882
5 changed files with 51 additions and 44 deletions

View File

@@ -1,44 +1,9 @@
import {hapTasks} from '@ohos/hvigor-ohos-plugin';
import fs from 'fs';
import path from 'path';
export function generatePushyBuildTime(str?: string) {
return {
pluginId: 'PushyBuildTimePlugin',
apply(pluginContext) {
pluginContext.registerTask({
name: 'pushy_build_time',
run: (taskContext) => {
const metaFilePath = path.resolve(__dirname, 'src/main/resources/rawfile/meta.json');
const dirPath = path.dirname(metaFilePath);
if (!fs.existsSync(dirPath)) {
fs.mkdirSync(dirPath, { recursive: true });
}
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(/"versionName":\s*"([^"]+)"/);
if (versionMatch && versionMatch[1]) {
versionName = versionMatch[1];
}
}
const buildTime = new Date().toISOString();
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']
})
}
}
}
import {reactNativeUpdatePlugin} from 'pushy/hvigor-plugin';
export default {
system: hapTasks, /* Built-in plugin of Hvigor. It cannot be modified. */
plugins:[generatePushyBuildTime()] /* Custom plugin to extend the functionality of Hvigor. */
}
system: hapTasks /* Built-in plugin of Hvigor. It cannot be modified. */,
plugins: [
reactNativeUpdatePlugin(),
] /* Custom plugin to extend the functionality of Hvigor. */,
};

View File

@@ -1,6 +1,7 @@
{
"modelVersion": "5.0.0",
"dependencies": {
pushy: 'file:../../node_modules/react-native-update/harmony/pushy'
},
"execution": {
// "analyze": "normal", /* Define the build analyze mode. Value: [ "normal" | "advanced" | false ]. Default: "normal" */

View File

@@ -8,7 +8,7 @@
"lint": "eslint .",
"start": "npm run codegen && hdc rport tcp:8081 tcp:8081 && react-native start",
"codegen": "react-native codegen-harmony --rnoh-module-path ./harmony/react_native_openharmony",
"build": "pushy bundle --platform harmony",
"build": "pushy bundle --platform harmony --no-interactive",
"test": "jest",
"hdiffFromPPK": "pushy hdiffFromPPK .pushy/output/harmony.1735052610653.ppk .pushy/output/harmony.1735052678646.ppk .pushy/output/hdiff.ppk-patch",
"hdiffFromApp": "pushy hdiffFromApp .pushy/output/version-1.0.0.app .pushy/output/harmony.1735052610653.ppk .pushy/output/hdiff.app-patch",

View File

@@ -0,0 +1,41 @@
import fs from 'fs';
import path from 'path';
export function reactNativeUpdatePlugin() {
return {
pluginId: 'reactNativeUpdatePlugin',
apply(node) {
node.registerTask({
name: 'reactNativeUpdatePlugin',
run: () => {
const cwd = process.cwd();
const metaFilePath = path.resolve(
cwd,
'entry/src/main/resources/rawfile/meta.json',
);
fs.mkdirSync(path.dirname(metaFilePath), { recursive: true });
const moduleJsonPath = path.resolve(cwd, 'AppScope/app.json5');
let versionName = '';
if (fs.existsSync(moduleJsonPath)) {
const content = fs.readFileSync(moduleJsonPath, 'utf-8');
const match = content.match(
/(?:"versionName"|versionName):\s*["']([^"']+)["']/,
);
versionName = match?.[1] || '';
}
const metaContent = {
pushy_build_time: new Date().toISOString(),
versionName,
};
fs.writeFileSync(metaFilePath, JSON.stringify(metaContent, null, 4));
console.log(`Build time written to ${metaFilePath}`);
},
dependencies: [],
postDependencies: ['default@BuildJS'],
});
},
};
}

View File

@@ -1,6 +1,6 @@
{
"name": "react-native-update",
"version": "10.35.2",
"version": "10.35.3",
"description": "react-native hot update",
"main": "src/index",
"scripts": {