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:
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'],
|
||||
});
|
||||
},
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user