1
0
mirror of https://gitcode.com/gh_mirrors/re/react-native-pushy.git synced 2025-10-29 04:23:10 +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

@@ -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'],
});
},
};
}