mirror of
https://gitcode.com/gh_mirrors/re/react-native-pushy.git
synced 2025-10-28 20:13:10 +08:00
fix hvigor plugin
This commit is contained in:
@@ -1,44 +1,9 @@
|
|||||||
import {hapTasks} from '@ohos/hvigor-ohos-plugin';
|
import {hapTasks} from '@ohos/hvigor-ohos-plugin';
|
||||||
import fs from 'fs';
|
import {reactNativeUpdatePlugin} from 'pushy/hvigor-plugin';
|
||||||
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']
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
system: hapTasks, /* Built-in plugin of Hvigor. It cannot be modified. */
|
system: hapTasks /* Built-in plugin of Hvigor. It cannot be modified. */,
|
||||||
plugins:[generatePushyBuildTime()] /* Custom plugin to extend the functionality of Hvigor. */
|
plugins: [
|
||||||
}
|
reactNativeUpdatePlugin(),
|
||||||
|
] /* Custom plugin to extend the functionality of Hvigor. */,
|
||||||
|
};
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
{
|
{
|
||||||
"modelVersion": "5.0.0",
|
"modelVersion": "5.0.0",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
pushy: 'file:../../node_modules/react-native-update/harmony/pushy'
|
||||||
},
|
},
|
||||||
"execution": {
|
"execution": {
|
||||||
// "analyze": "normal", /* Define the build analyze mode. Value: [ "normal" | "advanced" | false ]. Default: "normal" */
|
// "analyze": "normal", /* Define the build analyze mode. Value: [ "normal" | "advanced" | false ]. Default: "normal" */
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
"lint": "eslint .",
|
"lint": "eslint .",
|
||||||
"start": "npm run codegen && hdc rport tcp:8081 tcp:8081 && react-native start",
|
"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",
|
"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",
|
"test": "jest",
|
||||||
"hdiffFromPPK": "pushy hdiffFromPPK .pushy/output/harmony.1735052610653.ppk .pushy/output/harmony.1735052678646.ppk .pushy/output/hdiff.ppk-patch",
|
"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",
|
"hdiffFromApp": "pushy hdiffFromApp .pushy/output/version-1.0.0.app .pushy/output/harmony.1735052610653.ppk .pushy/output/hdiff.app-patch",
|
||||||
|
|||||||
41
harmony/pushy/hvigor-plugin.ts
Normal file
41
harmony/pushy/hvigor-plugin.ts
Normal 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'],
|
||||||
|
});
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "react-native-update",
|
"name": "react-native-update",
|
||||||
"version": "10.35.2",
|
"version": "10.35.3",
|
||||||
"description": "react-native hot update",
|
"description": "react-native hot update",
|
||||||
"main": "src/index",
|
"main": "src/index",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|||||||
Reference in New Issue
Block a user